package com.yunsc.common.annotation;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.yunsc.common.desensitize.DesensitizeSerializer;
import com.yunsc.common.desensitize.DesensitizeType;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @version: 1.0
 * @Author: adan
 * @description: 自定义注解，用于标记需要脱敏的字段
 * @date: 2024-05-08 21:59
 */
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@JsonSerialize(using = DesensitizeSerializer.class)
@JacksonAnnotationsInside
public @interface JsonDesensitize {

    /**
     * 脱敏类型
     * @return 脱敏类型
     */
    DesensitizeType type();

    /**
     * 脱敏符号
     */
    String symbol() default "*";

    /**
     * 脱敏长度
     */
    int length() default -1;

    /**
     * 脱敏正则表达式
     */
    String regex() default "";

    /**
     * 匹配的组
     */
    int group() default 0;


}
